#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a>b) swap(a,b);
    if (a>c) swap(a,c);
    if (b>c) swap(b,c);
    string s;
    cin>>s;
    for (int i=0; i<3; i++){
        switch (s[i])
        {
        case 'A':
            cout<<a<<" ";
            break;
        case 'B':
            cout<<b<<" ";
            break;
        case 'C':
            cout<<c<<" ";
            break;
        default:
            break;
        }
    }
    return 0;
}